package cn.venny.doudian.controller;

import cn.venny.doudian.entity.PddAllAreas;
import cn.venny.doudian.entity.PddAllLogistics;
import cn.venny.doudian.exception.ApiException;
import cn.venny.doudian.model.bean.DoudianAddressAllAreas;
import cn.venny.doudian.service.DoudianService;
import cn.venny.doudian.service.IPddAllAreasService;
import cn.venny.doudian.service.IPddAllLogisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author Vick C
 * @date 2021/4/20
 */
@RestController
@RequestMapping("/logistic")
public class PddAllAreasController {

    @Autowired
    DoudianService doudianService;
    @Autowired
    IPddAllAreasService pddAllAreasService;

    @PostMapping("/sync")
    public String syncPddAllLogistics(@RequestBody Map<String, Object> params) throws ApiException {
        List<DoudianAddressAllAreas> allAreas = doudianService.getAllAreas(params);
        pddAllAreasService.syncData(allAreas);
        return "success";
    }
}
